<template>
  <div :class="tableHeaderYC?'tableHeaderYC':''" class="avue-crud">
    <el-table :data="dataList" height="calc((100vh - 80px - 70px) / 2 - 100px)">
      <el-table-column prop="hdName" label="会议名称">
      </el-table-column>
<!--      <el-table-column prop="hdSm" label="会议说明">-->
<!--      </el-table-column>-->
<!--      <el-table-column prop="hdCppfs" label="测评票方式" width="180">-->
<!--      </el-table-column>-->
      <el-table-column label="操作" width="130">
        <template slot-scope="scope">
          <el-button type="primary" plain @click="cepingDf(scope.row.id)">测评
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <div v-if="false" class="avue-crud__pagination">
      <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex" :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage" background layout="total, sizes, prev, pager, next, jumper">
      </el-pagination>
    </div>
    <!-- 测评打分 -->
<!--    <cpIndex ref="cpIndex" @next="reloadHd"></cpIndex>-->
    <cePingIndex ref="cePingIndex" @next="reloadHd" />
  </div>
</template>

<script>
import {
  wdHuoDong
} from "@/api/ceping/cepinghdglb";
import{fetchList} from "@/api/activiti/task.js"
import {wdXuanPiao} from "@/api/ceping/cepinghdglxpxxb";
import cpIndex from "@/page/ceping/leaders/cpIndex";
import cePingIndex from '@/page/ceping/leaders/cpIndex-index';
import {
  mapGetters
} from 'vuex'
export default {
  data() {
    return {
      dataForm: {
        key: ''
      },
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      addOrUpdateVisible: false
    }
  },
  created() {
    this.loadData();
  },
  components: {
   //cpIndex,
    cePingIndex
  },
  computed: {
    ...mapGetters(['permissions'])
  },
  props: {
    tableHeaderYC: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    loadData() {
      this.dataListLoading = true
      wdHuoDong().then(res => {
       
        this.dataList = res.data.data;
        this.dataListLoading = false
      })
    },
    // 获取数据列表 预览分页查询使用
    getDataList() {
      this.dataListLoading = true
      fetchList(Object.assign({
        current: this.pageIndex,
        size: this.pageSize
      })).then(response => {
        this.dataList = response.data.data.records
        this.totalPage = response.data.data.total
      })
      this.dataListLoading = false
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataList()
    },
    cepingDf(id) {
      // this.$nextTick(() => {
      //   this.$refs.cpIndex.initHd(id);
      // });
      wdXuanPiao(id).then(res => {
        if (res.data.data.length > 0) {
          this.$refs.cePingIndex.initHd(res.data.data,id);
        }
      })
    },
    reloadHd() {
      this.dataListLoading = true
      wdHuoDong().then(res => {
        this.dataList = res.data.data;
        this.$forceUpdate();
        if (this.dataList.length > 0) {
          this.cepingDf(this.dataList[0].id);
        }
        this.dataListLoading = false
      })
    },
  }
}

</script>
<style>
.tableHeaderYC .el-table__header-wrapper{
  display: none;
}
</style>
